﻿using MaterialDesignColors;
using MaterialDesignThemes.Wpf;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ZhuXingFamilys.ExportExcel.entity;
using ZhuXingFamilys.ExportExcel.utils;
using ZhuXingFamilys.ExportExcel;

namespace ZhuXingFamilys.ListComparison
{
    /// <summary>
    /// ListComparison.xaml 的交互逻辑
    /// </summary>
    public partial class ListComparison : Window
    {
        public ListComparison()
        {
            //ui库使用
            ColorZoneAssist.SetMode(new GroupBox(), ColorZoneMode.Light);
            Hue hue = new Hue("name", System.Windows.Media.Color.FromArgb(1, 2, 3, 4), System.Windows.Media.Color.FromArgb(1, 5, 6, 7));

            InitializeComponent();
        }
        // 高级选项
        private void Button1_OnClick(object sender, RoutedEventArgs e)
        {
            if (this.GJXX_SP.Visibility == Visibility.Hidden)
            {
                this.Button_GJXX.Content = "高级选项△";
                this.Height = this.Height + 110;
                this.GJXX_SP.Visibility = Visibility.Visible;
            }
            else if (this.GJXX_SP.Visibility == Visibility.Visible)
            {
                this.Button_GJXX.Content = "高级选项▽";
                this.Height = this.Height - 110;
                this.GJXX_SP.Visibility = Visibility.Hidden;
            }
        }
        // 立即新建
        private void Button2_OnClick(object sender, RoutedEventArgs e)
        {
            // 工程清单文件路径
            string GCQDFilePath = this.TextBox_GCQD.Text;
            // 造价清单文件路径
            string ZJQDFilePath = this.TextBox_ZJQD.Text;
            // 工程文件名称
            string WJMC = this.TextBox_WJMC.Text;
            // 匹配规则
            List<string> selectValue = new List<string>();
            UIElementCollection collection = this.sp_checkBox.Children;
            foreach (UIElement element in collection)
            {
                if (element is CheckBox)
                {
                    CheckBox CB = element as CheckBox;
                    if (CB.IsChecked == true)
                    {
                        selectValue.Add(CB.Name);
                    }
                }
            }

            if (string.IsNullOrEmpty(GCQDFilePath))
            {
                MessageBox.Show("BIM工程清单路径错误", "提示");
            }
            else if (string.IsNullOrEmpty(ZJQDFilePath))
            {
                MessageBox.Show("造价清单文件路径错误", "提示");
            }
            else if (string.IsNullOrEmpty(WJMC))
            {
                MessageBox.Show("请填写工程文件名称", "提示");
            }
            else if (selectValue.Count == 0)
            {
                MessageBox.Show("请选择匹配规则", "提示");
            }
            else
            {
                // 打开对比匹配窗口
                CompareMainWindow cmw = new CompareMainWindow(GCQDFilePath, ZJQDFilePath, WJMC, selectValue);
                this.Close();
                cmw.Show();
                cmw.Activate();
            }

        }

        // 浏览1
        private void LL1_OnClick(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDlg = new Microsoft.Win32.OpenFileDialog();
            openFileDlg.DefaultExt = ".xls|.xlsx";
            openFileDlg.Filter = "Excel|*.xls;*.xlsx";
            openFileDlg.Title = "BIM工程清单文件";
            Nullable<bool> result = openFileDlg.ShowDialog();
            // 显示名称
            if (result == true)
            {
                string path = openFileDlg.FileName;
                this.TextBox_GCQD.Text = path;
            }
        }
        // 浏览2
        private void LL2_OnClick(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDlg = new Microsoft.Win32.OpenFileDialog();
            openFileDlg.DefaultExt = ".xls|.xlsx";
            openFileDlg.Filter = "Excel|*.xls;*.xlsx";
            openFileDlg.Title = "BIM工程清单文件";
            bool? result = openFileDlg.ShowDialog();
            if (result == true)
            {
                string path = openFileDlg.FileName;
                this.TextBox_ZJQD.Text = path;
            }
        }

        private void Rule_OnChecked(object sender, RoutedEventArgs e)
        {
            // CheckBox cb = sender as CheckBox;
            // if ("规则1".Equals(cb.Name))
            // {
            //     this.规则2.IsChecked = false;
            // }
            // if ("规则2".Equals(cb.Name))
            // {
            //     this.规则1.IsChecked = false;
            // }
        }
    }
}
